package com.neusoft.service.impl;

import com.neusoft.entity.Disease;
import com.neusoft.mapper.DiseaseMapper;
import com.neusoft.service.DiseaseService;
import com.neusoft.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author akemihomurasama
 */
@Service
public class DiseaseServiceImpl implements DiseaseService {
    @Autowired
    private DiseaseMapper diseaseMapper;

    /**
     * 查询所有疾病
     *
     * @return 疾病列表
     */
    @Override
    public Result queryAllDisease() {
        return Result.ok(diseaseMapper.queryAllDisease());
    }

    /**
     * 分页查询疾病列表
     *
     * @param currentPage 当前页码
     * @param pageSize    每页条数
     * @return 疾病列表
     */
    @Override
    public Result queryDiseaseByPage(int currentPage, int pageSize) {
        return Result.ok(diseaseMapper.queryDiseaseByPage((currentPage - 1) * pageSize, pageSize));
    }

    /**
     * 查询疾病数量
     *
     * @return 疾病数量
     */
    @Override
    public Result queryDiseaseCount() {
        return Result.ok(diseaseMapper.queryDiseaseCount());

    }

    /**
     * 根据条件查询疾病列表
     *
     * @param disease 条件
     * @return 疾病列表
     */
    @Override
    public Result queryDiseaseByCondition(Disease disease, int currentPage, int pageSize) {
        return Result.ok(diseaseMapper.queryDiseaseByCondition(disease, (currentPage - 1) * pageSize, pageSize));
    }
}
